<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="../include/header.jsp" />
<script type="text/javascript" src="<c:url value='/htmlRes/js/jquery.form.js'/>"></script>
<script type="text/javascript" src="<c:url value='/htmlRes/js/fileUpload.js'/>"></script>
<script type="text/javascript" src="<c:url value='/htmlRes/js/tableAddDelete.js'/>"></script>
<script type="text/javaScript">
<!--
	/* pagination 페이지 링크 function */
	function listPage(){
		$('#writeForm').attr('action', '<c:url value="/user/userList.do"/>');
		$('#writeForm').submit();
	}
	
	function saveFormPage() {
		$('#writeForm').attr('action', '<c:url value="/user/userSave.do"/>');
		$('#writeForm').submit();
	}
	
	function fileDelete(){
		var userId = $.trim($('#sau_user_id').val());
		if(userId==''){
			return;
		}
		$.ajax({
			type : "POST" ,
			url : "<c:url value='/user/deleteUserPic.do'/>",
			dataType: 'html',
			data : 'sau_user_id='+userId,
			success: function(data) {
				if(data == "true"){
					$('#sau_user_pic').val('');
					$('#fileInfo').html('');
					$('#imgPreview').attr("src","<c:url value='/htmlRes/images/img_thum02.jpg' />");
				}else{
					alert("이미지 삭제 실패!");
				};
			}, 
			error: function(request, status, err) {
				alert(request.status);
			}
		});
	}
	
	var fileOtions;
	$(document).ready(function(){
		fileOtions = {fileObjId:"file",toObj:"sau_user_pic",showImg:"imgPreview",showFileInfo:"fileInfo"};
		
		$('#certTableApdRow').click(function(e){
			e.preventDefault();
			$('#userCertTable').appendRow({sampleTRObj:"sampleTr"});
		});
		$('#certTableDelRow').click(function(e){
			e.preventDefault();
			$('#userCertTable').deleteRow();
		});
		$('#careerTableApdRow').click(function(e){
			e.preventDefault();
			$('#userCareerTable').appendRow({sampleTRObj:"careerSampleTr"});
		});
		$('#careerTableDelRow').click(function(e){
			e.preventDefault();
			$('#userCareerTable').deleteRow();
		});
	});
	
	
-->
</script>
<!-- contents s -->
<div class="container" id="container">
	<span class="round lt">&nbsp;</span>
	<span class="round rt">&nbsp;</span>
	<span class="round lb">&nbsp;</span>
	<span class="round rb">&nbsp;</span>
	<div class="container_area">
	<form name="writeForm" id="writeForm" action="<c:url value="/user/userWriteForm.do"/>" method="post">
		<input type="hidden" name="sau_user_pic" id="sau_user_pic" value="${resultVO.sau_user_pic }"/>
		<input type="hidden" name="sau_user_id" id="sau_user_id" value="${resultVO.sau_user_id }"/>
		<h2 class="tit_h2">담당자 등록</h2>
			<jsp:include page="../include/navi.jsp" />
			<h3 class="tit_h3">기본 정보</h3>
			<div class="table_wrap">
				<table summary="기본 정보 등록 입니다" class="table_write">
					<caption>기본 정보 등록</caption>
					<colgroup> <!-- D : col width로 테이블 넓이 조절 -->
						<col width="18%" />
                           <col width="10%" />
                           <col width="31%" />
                           <col width="10%" />
                           <col width="31%" />
					</colgroup>
					<tbody>
						<tr>
							<th scope="row" rowspan="4" class="bdR table_img">
                               	<div class="table_img_box" >
                               		<c:if test="${empty resultVO.sau_user_pic }">
										<img id="imgPreview" src="<c:url value='/htmlRes/images/img_thum02.jpg' />" alt="디폴트 이미지"/>
									</c:if>
									<c:if test="${not empty resultVO.sau_user_pic }">
	                                   	<img id="imgPreview" src="<c:if test="${not empty tempUrl }"><c:url value='${tempUrl }' />/</c:if><c:url value='${resultVO.sau_user_pic }' />" />
									</c:if>
								</div>
							</th>
							<th scope="row"><label for="sau_user_name">이름</label></th>
							<td class="alL">
								<input type="text" name="sau_user_name" id="sau_user_name" value="${resultVO.sau_user_name }" class="width_80"/>
								<span style="color: red">${error_sau_user_name}</span>
							</td>
							<th scope="row"><label for="sau_user_email">이메일</label></th>
							<td class="alL">
								<input type="text" name="sau_user_email" id="sau_user_email" value="${resultVO.sau_user_email }" class="width_80"/>
								<span style="color: red">${error_sau_user_email}</span>
							</td>
						</tr>
						<tr>                                
							<th scope="row"><label for="sau_user_tel1">전화 번호</label></th>
							<td class="alL" colspan="3">
								<input type="text" name="sau_user_tel1" id="sau_user_tel1" value="${resultVO.sau_user_tel1 }" title="전화번호 앞자리를 선택하세요" "/> -
								<input type="text" name="sau_user_tel2" id="sau_user_tel2" value="${resultVO.sau_user_tel2 }" title="전화번호 중간자리를 선택하세요" "/> -
								<input type="text" name="sau_user_tel3" id="sau_user_tel3" value="${resultVO.sau_user_tel3 }" title="전화번호 마지막자리를 선택하세요" "/>
							</td>
						</tr>
						<tr>
							<th scope="row"><label for="sau_user_hp1">휴대폰번호</label></th>
							<td class="alL" colspan="3">
								<input type="text" name="sau_user_hp1" id="sau_user_hp1" value="${resultVO.sau_user_hp1 }" title="휴대폰번호 앞자리를 선택하세요" "/> -
								<input type="text" name="sau_user_hp2" id="sau_user_hp2" value="${resultVO.sau_user_hp2 }" title="휴대폰번호 중간자리를 선택하세요" "/> -
								<input type="text" name="sau_user_hp3" id="sau_user_hp3" value="${resultVO.sau_user_hp3 }" title="휴대폰번호 마지막자리를 선택하세요" "/>
							</td>
						</tr>
                    	<tr>
                    		<th scope="row">사진 선택</th>
                        	<td colspan="3" class="alL">	
	                        	<input type="file" name="file" id="file" onchange="uploadFile(fileOtions);"/>
	                        	<span id="fileInfo">
		                        	<c:if test="${not empty resultVO.sau_user_pic }">
			                        	<a href="#fileDelete" id="fileDelete" class="btn_gy" onclick="fileDelete();return false;">이미지 삭제</a>
		                        	</c:if>
	                        	</span>
							</td>
                    	</tr>
                    	<c:if test="${loginSessionInfo.admin }">
                    	<tr>
                    		<th scope="row">상태</th>
                        	<td colspan="3" class="alL">	
	                        	<ul class="table_radio_area">
	                            	<li><label for="sau_flag_ynY">사용</label><input type="radio" name="sau_flag_yn" id="sau_flag_ynY" value="Y" <c:if test="${resultVO.sau_flag_yn eq 'Y' or empty resultVO.sau_flag_yn}">checked="checked"</c:if> /></li>
	                                <li><label for="sau_flag_ynN">삭제</label><input type="radio" name="sau_flag_yn" id="sau_flag_ynN" value="N" <c:if test="${resultVO.sau_flag_yn eq 'N' }">checked="checked"</c:if>/></li>
	                            </ul>
							</td>
                    	</tr>
                    	</c:if>
					</tbody>
				</table>
			</div>
			
			<h3 class="tit_h3">자격증</h3>
			<div class="btn_bbs type_pm">
				<a href="#appendRow" class="btn_pm" id="certTableApdRow">+</a>
				<a href="#deleteRow" class="btn_pm" id="certTableDelRow">-</a>
			</div>
			<div class="table_wrap">
				<table summary="자격증 테이블 입니다" class="table_list" id="userCertTable">
					<caption>자격증</caption>
					<colgroup> <!-- D : col width로 테이블 넓이 조절 -->
						<col width="40%" />
                           <col width="40%" />
                           <col width="20%" />
					</colgroup>
					<thead>
						<tr>
							<th scope="col">자격증/면허증</th>
                            <th scope="col">발행처/발행기관</th>
                            <th scope="col">취득일</th>
						</tr>
					</thead>
					<tbody>
					<c:if test="${empty resultVO.userCertVOList}">
						<tr id="sampleTr">
							<td><input type="text" name="userCertVOList[0].sac_cert_name" title="자격증/면허증" class="input_max"/></td>
							<td><input type="text" name="userCertVOList[0].sac_cert_publish" title="발행처/발행기관" class="input_max"/></td>
							<td><input type="text" name="userCertVOList[0].sac_cert_date" title="취득일" class="input_max"/></td>
						</tr>		
						</c:if>
						<c:if test="${not empty resultVO.userCertVOList}">
							<c:forEach var="result" items="${resultVO.userCertVOList }" varStatus="status"> 
							<tr <c:if test="${status.first }">id="sampleTr"</c:if>>
								<td><input type="text" name="userCertVOList[${status.count-1}].sac_cert_name"  value="${result.sac_cert_name }" title="자격증/면허증" class="input_max"/></td>
								<td><input type="text" name="userCertVOList[${status.count-1}].sac_cert_publish"  value="${result.sac_cert_publish }" title="발행처/발행기관" class="input_max"/></td>
								<td><input type="text" name="userCertVOList[${status.count-1}].sac_cert_date"  value="${result.sac_cert_date }" title="취득일" class="input_max"/></td>
							</tr>		
							</c:forEach>
						</c:if>
					</tbody>
				</table>
			</div><!--//table_wrap-->
			
			<h3 class="tit_h3">경력 사항</h3>
			<div class="btn_bbs type_pm">
				<a href="#appendRow" class="btn_pm" id="careerTableApdRow">+</a>
				<a href="#deleteRow" class="btn_pm" id="careerTableDelRow">-</a>
			</div>
			<div class="table_wrap">
				<table summary="경력 사항 테이블 입니다" class="table_list" id="userCareerTable">
					<caption>경력 사항</caption>
					<colgroup> <!-- D : col width로 테이블 넓이 조절 -->
						<col width="25%" />
                           <col width="25%" />
                           <col width="50%" />
					</colgroup>
					<thead>
						<tr>
							<th scope="col">기간</th>
							<th scope="col">회사명</th>
							<th scope="col">업무내용</th>
						</tr>
					</thead>
					<tbody>
					<c:if test="${empty resultVO.userCareerVOList}">	
					<tr id="careerSampleTr">
						<td><input type="text" name="userCareerVOList[0].sac_biz_period" title="기간" class="input_max"/></td>
						<td><input type="text" name="userCareerVOList[0].sac_com_name"  title="회사명" class="input_max"/></td>
						<td><input type="text" name="userCareerVOList[0].sac_biz_cont" title="업무내용" class="input_max"/></td>
					</tr>
					</c:if>
					<c:if test="${not empty resultVO.userCareerVOList}">	
						<c:forEach var="result" items="${resultVO.userCareerVOList }" varStatus="status"> 
					<tr <c:if test="${status.first }">id="careerSampleTr"</c:if>>
						<td><input type="text" name="userCareerVOList[${status.count-1}].sac_biz_period"  value="${result.sac_biz_period }" title="기간" class="input_max"/></td>
						<td><input type="text" name="userCareerVOList[${status.count-1}].sac_com_name"  value="${result.sac_com_name }" title="회사명" class="input_max"/></td>
						<td><input type="text" name="userCareerVOList[${status.count-1}].sac_biz_cont"  value="${result.sac_biz_cont }" title="업무내용" class="input_max"/></td>
					</tr>
						</c:forEach>
					</c:if>
					</tbody>
				</table>
			</div><!--//table_wrap-->
			
			<div class="btn_bbs">
				<c:if test="${loginSessionInfo.admin }">
				<a href="<c:url value='/user/userList.do' />" onclick="listPage();return false;" class="btn_wh">목록</a>
				</c:if>
				<a href="<c:url value='/user/userSave.do' />" onclick="saveFormPage();return false;" class="btn_re">저장</a>
			</div>
			<!-- 검색조건 유지 -->
			<input type="hidden" name="pageIndex" id="pageIndex" value="${resultVO.pageIndex }"/>
		</form>
	</div><!--//container_area-->
</div>
<!-- contents e -->
<jsp:include page="../include/fileUpload.jsp" flush="true"/>
<jsp:include page="../include/footer.jsp" flush="true"/>
<jsp:include page="../include/messagealert.jsp" />